<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('查看产品信息')" />
    <th:block th:include="include :: ztree-css" />
</head>
<body class="white-bg">
<div id="showDetail" class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" name="fma" id="form-manage-add" th:object="${photo}">
        <input type="hidden" id="phoGalId" name="phoGalId" th:field="*{phoGalId}" />
        <div class="form-group">
            <label class="col-sm-3 control-label">展示：</label>
            <div class="col-sm-8">
                <img th:src="*{phoGalImg}"  id="phoGalImg" width="50%" height="50%"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">排序值：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="phoGalSort" id="phoGalSort" th:field="*{phoGalSort}"   required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">是否显示：</label>
            <div class="col-sm-8">
                <label class="toggle-switch switch-solid">
                    <input type="checkbox" id="phoGalShow" th:checked="${photo.phoGalShow == 1 ? true : false}">
                    <span></span>
                </label>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var perImg = ctx + "img/";

    /* 获取src值 */
    var imgSrc = $("#phoGalImg").attr("src");

    /* 填充src值 */
    $("#phoGalImg").attr("src",perImg + imgSrc);



    function edit() {
        var phoGalId = $("input[name='phoGalId']").val();
        var phoGalSort = $("input[name='phoGalSort']").val();
        var phoGalShow = $("input[id='phoGalShow']").is(':checked') == true ? 1 : 0;
        $.ajax({
            cache : true,
            type : "POST",
            url : ctx + "datum/manage/editPhoto",
            data : {
                "phoGalId": phoGalId,
                "phoGalSort": phoGalSort,
                "phoGalShow": phoGalShow,
            },
            async : false,
            error : function(request) {
                $.modal.alertError("系统错误");
            },
            success : function(data) {
                $.operate.successCallback(data);
            }
        });
    }

    function submitHandler() {
        if ($.validate.form()) {
            edit();
        }
    }

</script>
</body>
</html>
